package com.atguigu.springcloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * 创建配置类，并且将restTemplate放入容器管理
 *
 * @author Tu
 * @date 2022/11/20 20:50
 */
@Configuration
public class ApplicationContextConfig {

    /**
     * @LoadBalanced：自定义策略要去除该注解，否则无法调用
     *
     * @return
     * @LoadBalanced 注解配合集群实现负载均衡
     */
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }

}
